//package com.liuyu.common.framework.drools;
//
//import org.kie.api.KieServices;
//import org.kie.api.command.Command;
//import org.kie.api.command.KieCommands;
//
///**
// *
// * @author: liuyu
// * @date: 2021/11/2 16:17
// * @version:
// */
//public class KieServerClientTest {
//
//    private static String url        = "http://192.168.236.101:8080/kie-server/services/rest/server";
//    private static String username   = "kieserver";
//    private static String password   = "kieserver";
//    private static String container  = "drools";
//    private static String kieSession = "kiesession1";
//
//    public static void main(String[] args) {
//        //bean 路径必须与kie-web上的bean 路径包名字段完全相同
//        Person person = new Person();
//        person.setAge(11);
//        person.setName("ccy");
//        KieServicesConfiguration config = KieServicesFactory.newRestConfiguration(url, username, password);
//        config.setMarshallingFormat(MarshallingFormat.JSON);
//        config.setTimeout(30000L);
//
//        KieServicesClient client = KieServicesFactory.newKieServicesClient(config);
//        RuleServicesClient rules = client.getServicesClient(RuleServicesClient.class);
//
//        KieCommands cmdFactory = KieServices.Factory.get().getCommands();
//
//        List<Command<?>> commands = new LinkedList<Command<?>>();
//        commands.add(cmdFactory.newInsert(person, "person"));
//        commands.add(cmdFactory.newFireAllRules());
//        ServiceResponse<org.kie.api.runtime.ExecutionResults> response = rules.executeCommandsWithResults(container,
//                cmdFactory.newBatchExecution(commands, kieSession));
//
//        System.out.println(response.getMsg());
//        ExecutionResults result = response.getResult();
//        person = (Person) result.getValue("person");
//        System.out.println(person.getName());
//
//    }
//
//}
